{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "89aab9ff",
   "metadata": {},
   "source": [
    "# 产品需求文档\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4aaa8a07",
   "metadata": {},
   "source": [
    "### 产品描述：\n",
    "* 针对15岁至55岁的人群 设计一款能识别照片中出现的中外著名地表、景点的小程序/APP应用 为旅行爱好者提供服务\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "### 产品类型：微信小程序/APP应用"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fe97502b",
   "metadata": {},
   "source": [
    "### 核心价值： \n",
    "* 将地标识别服务集成到识图APP/小程序中，识别照片中出现的中外著名地标、景点，广泛应用于综合识图场景；\n",
    "* 集成地标识别服务，实现自动给地标、景点图片打标签并进行分类，适用于旅游类网站/APP和智能相册\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7202556e",
   "metadata": {},
   "source": [
    "#### 发展优势\n",
    "* 能够快速识别微信朋友圈中打卡照片，多功能交叉使用。\n",
    "* 新型冠状病毒肆虐下，人们旅行需求被压制住，为将来的报复性旅行消费做准备。\n",
    "* 目前该类型产品较少或不完善，发展空间辽阔，"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4cfefc82",
   "metadata": {},
   "source": [
    "##### IDEO三要素：\n",
    "\n",
    "_Desirability用户可欲性：满足对一些对旅行爱好者的用户来识别景点、地表的需求，通过与其它功能交叉迭代，拓展核心价值，并可以丰富相关知识_ \n",
    "\n",
    "\n",
    "_Viability商业可行性：市场上图像识别类小程序数量较多，但是该产品具有一定创新型，可以吸引那些旅行爱好者的用户_ \n",
    "\n",
    "\n",
    "_Feasibility技术可行性：百度ai平台可以提供地标识别的api，微信小程序上手简单快捷_"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "de1cdadc",
   "metadata": {},
   "source": [
    "#### 用户痛点：\n",
    "\n",
    "* 不清楚这是某个景点地标\n",
    "\n",
    "\n",
    "* 看到景点地标很熟悉，但是不清楚名字\n",
    "\n",
    "\n",
    "* 想要了解更多该地相关的出行、饮食、风俗需求等"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c27d45e5",
   "metadata": {},
   "source": [
    "#### 用户画像\n",
    "* 小谢 男 15岁 中学生 恰逢初升高的暑假，希望开拓自己的视野，打算去各地著名景点打卡，从照片上看到许多景点，但不知道这是何地。\n",
    "* 老唐 男 45岁 地理教师/旅行爱好者 希望能实现更加便捷的出行，领略更多的风土人情，"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2ee68eed",
   "metadata": {},
   "source": [
    "## 获取token"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "67d44843",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'refresh_token': '25.0051cf8a0b7c6c5d978b45e1dfe4d523.315360000.1965048602.282335-25863373', 'expires_in': 2592000, 'session_key': '9mzdC32qM31R4YDnymTCWj/CDmPm72vaSbXqlmjjDbQXkguiRFJ8ylJ7AwvJaQ2Z3CklmGeORCAeRthkXIspZ7wzUIQfkg==', 'access_token': '24.0e065c7b49023b973f547b5b23202bc3.2592000.1652280602.282335-25863373', 'scope': 'public vis-classify_dishes vis-classify_car brain_all_scope vis-classify_animal vis-classify_plant brain_object_detect brain_realtime_logo brain_dish_detect brain_car_detect brain_animal_classify brain_plant_classify brain_ingredient brain_advanced_general_classify brain_custom_dish brain_poi_recognize brain_vehicle_detect brain_redwine brain_currency brain_vehicle_damage brain_multi_ object_detect wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test权限 vis-classify_flower lpq_开放 cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base smartapp_mapp_dev_manage iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi fake_face_detect_开放Scope vis-ocr_虚拟人物助理 idl-video_虚拟人物助理 smartapp_component smartapp_search_plugin avatar_video_test b2b_tp_openapi b2b_tp_openapi_online', 'session_secret': '7d45b26080c16fd0c28924dd7e5e8ef3'}\n"
     ]
    }
   ],
   "source": [
    "# encoding:utf-8\n",
    "import requests \n",
    "\n",
    "# client_id 为官网获取的AK， client_secret 为官网获取的SK\n",
    "host = 'https://aip.baidubce.com/oauth/2.0/token?'\n",
    "payload = {\n",
    "    'grant_type':'client_credentials',\n",
    "    'client_id':'my2k7CN3u4D7YEK2N0Qf74M0',\n",
    "    'client_secret':'dxLb52rZi3gPBA603fMFs3A2cNrTvQOr'\n",
    "    \n",
    "}\n",
    "response = requests.get(host,params=payload)\n",
    "if response:\n",
    "    print(response.json())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "7db30f13",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'24.0e065c7b49023b973f547b5b23202bc3.2592000.1652280602.282335-25863373'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xiefan_AT = response.json()['access_token']\n",
    "xiefan_AT"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6a5b4a77",
   "metadata": {},
   "source": [
    "## 识别认证"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "0328164c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'result': {'landmark': '广州塔'}, 'log_id': 1513536342174331594}\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# encoding:utf-8\n",
    "\n",
    "import requests\n",
    "import base64\n",
    "\n",
    "'''\n",
    "地标识别\n",
    "'''\n",
    "\n",
    "request_url = \"https://aip.baidubce.com/rest/2.0/image-classify/v1/landmark\"\n",
    "# 二进制方式打开图片文件\n",
    "f = open('bb.jpg', 'rb')\n",
    "img = base64.b64encode(f.read())\n",
    "\n",
    "params = {\"image\":img}\n",
    "access_token = '24.0e065c7b49023b973f547b5b23202bc3.2592000.1652280602.282335-25863373'\n",
    "request_url = request_url + \"?access_token=\" + access_token\n",
    "headers = {'content-type': 'application/x-www-form-urlencoded'}\n",
    "response = requests.post(request_url, data=params, headers=headers)\n",
    "if response:\n",
    "    print (response.json())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b6fb59e9",
   "metadata": {},
   "source": [
    "## 封装函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "e220cde4",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "import base64\n",
    "def everything(token,image_path):\n",
    "    url = \"https://aip.baidubce.com/rest/2.0/image-classify/v1/landmark\"\n",
    "    # 二进制方式打开图片文件\n",
    "    f = open(image_path, 'rb')\n",
    "    img = base64.b64encode(f.read())\n",
    "    \n",
    "    params = {\n",
    "        \"image\":img,\n",
    "        \"access_token\": xiefan_AT\n",
    "         }\n",
    "    headers = {'content-type': 'application/x-www-form-urlencoded'}\n",
    "    response = requests.post(url, data=params, headers=headers)\n",
    "    return response.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "03164128",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'result': {'landmark': '东京湾跨海公路'}, 'log_id': 1513542987059181744}"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "landmark_info = everything(xiefan_AT,\"daqiao.jpg\")\n",
    "landmark_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "8fe60d9a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'result': {'landmark': '东京晴空塔'}, 'log_id': 1513543084229539779}"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "landmark_info = everything(xiefan_AT,\"qingkongta.jpg\")\n",
    "landmark_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "ff365c8c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'result': {'landmark': '清水寺'}, 'log_id': 1513543126612528752}"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "landmark_info = everything(xiefan_AT,\"qingshuisi.jpg\")\n",
    "landmark_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1fa71a55",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
